/*
 * p1631.cpp
 *
 *  Created on: 2013-4-19
 *      Author: zy
 */

#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
int a[40000];
int d[40000];
int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int n;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		int ans = 1;
		d[1]=a[1];
		for (int i = 2; i <= n; i++)
		{
			if (a[i] > d[ans])
			{
				ans++;
				d[ans]=a[i];
			}
			else
			{
				int l=1,r=ans,mid=(l+r)/2;
				while(l<r)
				{
					if(d[mid]>=a[i])r=mid;
					else l=mid+1;
					mid=(l+r)/2;
				}
				d[mid]=a[i];
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}
